
=== SYNOPSIS ===
{{{
#include <xp/sys/dll.h>

xp_dll_t* xp_dll_open (xp_dll_t* dll, const xp_char_t* path);
int xp_dll_close (xp_dll_t* dll);
void* xp_dll_lookup (xp_dll_t* dll, const xp_char_t* name);
}}}

=== DESCRIPTION ===
'''''xp_dll_open()''''' opens a dynamic library from the file '''''path''''', puts the handle into an '''''xp_dll_t''''' object and returns a pointer to it. It returns XP_NULL on failure. The returning object is dynamically created if '''''dll''''' is XP_NULL. Otherwise, '''''dll''''' is returned as it is.

'''''xp_dll_close()''''' closes the library previously opened by '''''xp_dll_open()'''''. It returns 0 on success and -1 on failure.

'''''xp_dll_lookup()''''' returns the address where the symbol '''''name''''' is loaded. It returns XP_NULL when the symbol is not found.

=== EXAMPLE ===
{{{
#include <xp/sys/dll.h>
#include <xp/bas/stdio.h>

int xp_main ()
{
	xp_dll_t dll;
	int (*sum) (int a, int b);

	if (xp_dll_open(&dll, XP_TEXT("./mylib.so")) == XP_NULL) {
		xp_fprintf (xp_stderr, XP_TEXT("cannot open library\n"));
		return -1;
	}

	sum = xp_dll_lookup(&dll, XP_TEXT("sum"));
	if (sum == XP_NULL) {
		xp_fprintf (xp_stderr, XP_TEXT("cannot find symbol\n"));
		xp_dll_close (&dll);
		return -1;
	}

	xp_printf (XP_TEXT("sum = %d\n"), sum (30, 40));
	xp_dll_close (&dll);

	return 0;
}
}}}

